<template>
    <div>
        <!-- <Banner :shops='imens'></Banner> -->
        <xiangqing :shop='imens'></xiangqing>
    </div>
</template>
<script>
import Banner from './components/Banner'
import xiangqing from './components/xiangqing'
import axios from 'axios'
export default {
    data(){
        return{
            ids:'',
            data:[],
            imens:{}
        }
    },
    components:{
        Banner,
        xiangqing
    },
    methods:{
         axios(){
            axios.get('/api/shop.json').then(this.success).catch(this.errors)
        },
        success(data){
            this.data=data.data.items;
            this.data.forEach(element => {
                 let reg = RegExp(/png/)
               let suffix = 'jpeg'
          if (reg.test(element.restaurant.image_path)) {
            suffix = 'png'
          }
          let imgpath = `${element.restaurant.image_path.slice(0,1)}/${element.restaurant.image_path.slice(1,3)}/${element.restaurant.image_path.slice(3)}`
          element.restaurant.image_path = `https://fuss10.elemecdn.com/${imgpath}.${suffix}%3FimageMogr2/thumbnail/130x130/format/webp/quality/85`
                let ree = 'png'
                if (!element.restaurant.recommend.is_ad) {
                let imgurl = `${element.restaurant.recommend.image_hash.slice(0,1)}/${element.restaurant.recommend.image_hash.slice(1,3)}/${element.restaurant.recommend.image_hash.slice(3)}`
                 element.restaurant.recommend.image_hash =`http://fuss10.elemecdn.com/${imgurl}.${ree}?imageMogr/format/webp/thumbnail/!60x60r/gravity/Center/crop/60x60/`
            }
                if(element.restaurant.id==this.ids){
                    this.imens=element
                    console.log('一',this.imens)
                }
            });
        },
        errors(err){
            console.log(err)
        }
    },
    mounted() {
        this.ids=this.$route.params.id
        this.axios()
    },
}
</script>
<style lang="stylus" scoped>

</style>

